package mutsumimod.monitors;

import basemod.interfaces.ISubscriber;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.*;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.vfx.AbstractGameEffect;

import javax.swing.*;

public class BaseMonitor implements ISubscriber {

    public void addToBot(AbstractGameAction action) {
        AbstractDungeon.actionManager.addToBottom(action);
    }

    public void addToTop(AbstractGameAction action) {
        AbstractDungeon.actionManager.addToTop(action);
    }

    public void gainEnergy(int amount){
        addToBot(new GainEnergyAction(amount));
    }

    public void drawCard(int amount) {
        addToBot(new DrawCardAction(AbstractDungeon.player, amount));
    }

    public void damageAllMonster(int baseDamage) {
        damageAllMonster(baseDamage,1,AbstractGameAction.AttackEffect.SLASH_VERTICAL);
    }

    public void damageAllMonster(int baseDamage,int damageTime) {
        damageAllMonster(baseDamage,damageTime,AbstractGameAction.AttackEffect.SLASH_VERTICAL);
    }

    public void damageAllMonster(int baseDamage,int damageTime,AbstractGameAction.AttackEffect effect) {
        for(int i=0;i<damageTime;i++){
            addToBot(new DamageAllEnemiesAction(AbstractDungeon.player, baseDamage, DamageInfo.DamageType.NORMAL , effect));
        }
    }

    public void damageMonster(int damage, AbstractMonster m) {
        damageMonster(damage,m,1, com.megacrit.cardcrawl.actions.AbstractGameAction.AttackEffect.SLASH_VERTICAL);
    }

    public void damageMonster(int damage, AbstractMonster m, int damageTime) {
        damageMonster(damage,m,damageTime,AbstractGameAction.AttackEffect.SLASH_VERTICAL);
    }

    public void damageMonster(int damage, AbstractMonster m, int damageTime, AbstractGameAction.AttackEffect effect) {
        for(int i=0;i<damageTime;i++){
            addToBot(new DamageAction(m, new DamageInfo(AbstractDungeon.player
                    , damage, DamageInfo.DamageType.NORMAL), effect));
        }
    }

    public void gainBlock(int block){
        addToBot(new GainBlockAction(AbstractDungeon.player, block));
    }


    public void reducePowerAndRemove(int amount,String powerID){
        if(AbstractDungeon.player.hasPower(powerID)){
            AbstractPower p = AbstractDungeon.player.getPower(powerID);
            if(p.amount>amount){
                addToBot(new ReducePowerAction(AbstractDungeon.player, AbstractDungeon.player, powerID, amount));
            }else{
                addToBot(new RemoveSpecificPowerAction(AbstractDungeon.player, AbstractDungeon.player, powerID));
            }
        }
    }

    public void applyPowerSelf(AbstractPower power,int magicNumber){
        if(magicNumber==0){
            addToBot(new ApplyPowerAction(AbstractDungeon.player, AbstractDungeon.player, power));
        }else{
            addToBot(new ApplyPowerAction(AbstractDungeon.player, AbstractDungeon.player, power,magicNumber));
        }
    }

    public void applyPowerMonster(AbstractPower power,int magicNumber,AbstractMonster m){
        if(magicNumber==0){
            addToBot(new ApplyPowerAction(m, AbstractDungeon.player, power));
        }else{
            addToBot(new ApplyPowerAction(m, AbstractDungeon.player, power,magicNumber));
        }
    }

}
